/******************************************************************
 *
 *    山东中软科
 *
 *    Copyright (c) 2019-2021
 *
 *    Package:     io.finer.erp.jeecg.finance.vo
 *
 *    Filename:    PurchaseOrderVO.java
 *
 *    Description: 
 *
 *    Copyright:   Copyright (c) 2019-2021
 *
 *    Company:     山东中软科
 *
 *    @author:     duany
 *
 *    @version:    1.0.0
 *
 *    Create at:   2021-06-12 15:28:29
 *
 *    Revision:
 *
 *    2021-06-12 15:28:29 - first revision by duany
 *
 *    Function List:
 *
 *****************************************************************/

package io.finer.erp.jeecg.finance.vo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
import org.springframework.format.annotation.DateTimeFormat;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @ClassName PurchaseOrderVO
 * @Description 
 * @author duany
 * @Date 2021-06-12 15:28:29
 * @version 1.0.0
 */
@Data
public class PurchaseOrderVO {
	/**ID*/
    @ApiModelProperty(value = "ID")
    private java.lang.String id;
	/**出入库类型*/
    @ApiModelProperty(value = "出入库类型")
    @Dict(dicCode = "x_stock_io_type")
    private java.lang.String stockIoType;
	/**单据编号*/
    @Excel(name = "单据编号", width = 15)
    @ApiModelProperty(value = "单据编号")
    private java.lang.String billNo;
	/**供应商*/
    @Excel(name = "供应商", width = 15, dictTable = "bas_supplier", dicText = "name", dicCode = "id")
    @ApiModelProperty(value = "供应商")
    @Dict(dictTable = "bas_supplier", dicText = "name", dicCode = "id")
    private java.lang.String supplierId;
    /**单据日期*/
    @ApiModelProperty(value = "单据日期字符串")
    private java.lang.String billDateText;
	/**源单类型*/
    @ApiModelProperty(value = "源单类型")
    private java.lang.String sourceType;
	/**源单*/
    @ApiModelProperty(value = "源单")
    private java.lang.String sourceId;
	/**创建人*/
	@Excel(name = "制单人", width = 15, dictTable = "sys_user", dicText = "realname", dicCode = "username")
    @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
    @ApiModelProperty(value = "创建人")
    private java.lang.String createBy;
	/**业务员*/
    @Excel(name = "业务员", width = 15, dictTable = "sys_user", dicText = "realname", dicCode = "username")
    @ApiModelProperty(value = "业务员")
    @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
    private java.lang.String clerkId;
    /**业务员名称*/
    @ApiModelProperty(value = "业务员名称")
    private java.lang.String clerkIdText;
	/**出入库经办*/
    @ApiModelProperty(value = "出入库经办")
    @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
    private java.lang.String handlerId;
    /**出入库经办名称*/
    @ApiModelProperty(value = "出入库经办名称")
    private java.lang.String handlerIdText;
    /**供应商名称*/
    @ApiModelProperty(value = "供应商名称")
    private java.lang.String supplierIdText;
	/**附件*/
    @ApiModelProperty(value = "附件")
    private java.lang.String attachment;
	/**处理状态*/
	@Excel(name = "处理状态", width = 15, dicCode = "x_bill_proc_status")
    @ApiModelProperty(value = "处理状态")
    @Dict(dicCode = "x_bill_proc_status")
    private java.lang.String billProcStatus;
	/**备注*/
	@Excel(name = "备注", width = 15)
    @ApiModelProperty(value = "备注")
    private java.lang.String remark;
	/**单据日期*/
    @Excel(name = "单据日期", width = 15, format = "yyyy-MM-dd")
    @ApiModelProperty(value = "单据日期")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private java.util.Date billDate;
    /**生效时间*/
    @Excel(name = "生效时间", width = 15, format = "yyyy-MM-dd")
    @ApiModelProperty(value = "生效时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private java.util.Date effectiveTime;
    /**审核人*/
    @Excel(name = "审核人", width = 15, dictTable = "sys_user", dicText = "realname", dicCode = "username")
    @ApiModelProperty(value = "审核人")
    @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
    private java.lang.String approverId;
	/**单据状态*/
    @ApiModelProperty(value = "单据状态")
    @Dict(dicCode = "x_bill_status")
    private java.lang.String billStatus;
    /**单据状态名称*/
    @ApiModelProperty(value = "单据状态名称")
    private java.lang.String billStatusText;
    /**审核人名称*/
    @ApiModelProperty(value = "审核人名称")
    private java.lang.String approverIdText;
	/**是否通过*/
//    @Excel(name = "是否通过", width = 15, dicCode = "yn")
    @ApiModelProperty(value = "是否通过")
    @Dict(dicCode = "yn")
    private java.lang.Integer isApproved;
	/**是否通过*/
    @ApiModelProperty(value = "是否通过")
    private java.lang.String isApprovedText;
    /**生效时间字符串*/
    @ApiModelProperty(value = "生效时间字符串")
    private java.lang.String effectiveTimeText;
	/**是否作废*/
//	@Excel(name = "是否作废", width = 15, dicCode = "yn")
    @Dict(dicCode = "yn")
    @ApiModelProperty(value = "是否作废")
    private java.lang.Integer isVoided;
	/**是否作废字符串*/
    @ApiModelProperty(value = "是否作废字符串")
    private java.lang.String isVoidedText;
	/**是否关闭*/
    @ApiModelProperty(value = "是否关闭")
    @Dict(dicCode = "yn")
    private java.lang.Integer isClosed;
	/**是否关闭*/
    @ApiModelProperty(value = "是否关闭")
    private java.lang.String isClosedText;
	/**创建时间*/
    @Excel(name = "创建时间", width = 15, format = "yyyy-MM-dd")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private java.util.Date createTime;
	/**创建部门*/
    @Excel(name = "创建部门", width = 15, dictTable = "sys_depart", dicText = "depart_name", dicCode = "org_code")
    @Dict(dictTable = "sys_depart", dicText = "depart_name", dicCode = "org_code")
    @ApiModelProperty(value = "创建部门")
    private java.lang.String sysOrgCode;
    /**创建部门*/
	@ApiModelProperty(value = "创建部门字符串")
	private java.lang.String sysOrgCodeText;
    /**创建人名称*/
    @ApiModelProperty(value = "创建人名称")
    private java.lang.String createByText;
	/**创建时间*/
    @ApiModelProperty(value = "创建时间")
    private java.lang.String createTimeText;
	/**修改时间*/
    @Excel(name = "修改时间", width = 15, format = "yyyy-MM-dd")
    @ApiModelProperty(value = "修改时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private java.util.Date updateTime;
	/**修改人*/
    @Excel(name = "修改人", width = 15, dictTable = "sys_user", dicText = "realname", dicCode = "username")
    @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
    @ApiModelProperty(value = "修改人")
    private java.lang.String updateBy;
    /**修改人*/
    @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
    @ApiModelProperty(value = "修改人")
    private java.lang.String updateByText;
	/**修改时间*/
    @ApiModelProperty(value = "修改时间")
    private java.util.Date updateTimeText;
	/**版本*/
    @ApiModelProperty(value = "版本")
    private java.lang.Integer version;
    @ApiModelProperty(value = "处理状态Text")
    private String billProcStatusText;
	/**源单号*/
//	@Excel(name = "源单号", width = 15)
    @ApiModelProperty(value = "源单号")
    private java.lang.String sourceNo;
    /**是否开票*/
    @ApiModelProperty(value = "是否开票")
    @Dict(dicCode = "yn")
    private java.lang.String isInvoice;
	
	//明细信息
    @ExcelCollection(name="采购详情")
	private List<PurchaseOrderEntryVO> list;
	
    @TableField(exist = false)
    private Map actionsEnabled;

    public Map getActionsEnabled() {
        //controller中，QueryWrapper也会创建entity；
        //(actionsEnabled == null)，是为了避免作为查询数据库参数。
        if (id == null) {
            return null;
        }

        HashMap<String, Boolean> map = new HashMap<String, Boolean>();
        boolean b = billProcStatus != null && billProcStatus.startsWith("1")
                && (isApproved == null || isApproved == 0)
                && (isClosed == null || isClosed == 0)
                && (isVoided == null || isVoided == 0);
        map.put("edit", b);

        b = billProcStatus != null &&
                    billProcStatus.startsWith("1") && !billProcStatus.equals("13")
                && (isApproved == null || isApproved == 0)
                && (isClosed == null || isClosed == 0)
                && (isVoided == null || isVoided == 0)
                &&  approverId == null;
        map.put("delete", b);

        b =  billProcStatus != null && billProcStatus.equals("13")
                && (isApproved == null || isApproved == 0)
                && (isClosed == null || isClosed == 0)
                && (isVoided == null || isVoided == 0);
        map.put("approve", b);

        b = billProcStatus != null &&
                (billProcStatus.equals("23") ||
                        billProcStatus.startsWith("3") && !billProcStatus.equals("33"))
                && isApproved != null && isApproved == 1
                && (isClosed == null || isClosed == 0)
                && (isVoided == null || isVoided == 0);
        map.put("execute", b);

        actionsEnabled = map;
        return map;
    }
}
